package cn.iocoder.yudao.module.eval.dal.mysql.plan;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.eval.controller.admin.plan.vo.EvalPlanPageReqVO;
import cn.iocoder.yudao.module.eval.dal.dataobject.plan.EvalPlanDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * 评价计划 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EvalPlanMapper extends BaseMapperX<EvalPlanDO> {

    default PageResult<EvalPlanDO> selectPage(EvalPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EvalPlanDO>()
                .likeIfPresent(EvalPlanDO::getPlanName, reqVO.getPlanName())
                .likeIfPresent(EvalPlanDO::getPlanCode, reqVO.getPlanCode())
                .eqIfPresent(EvalPlanDO::getProfessionId, reqVO.getProfessionId())
                .likeIfPresent(EvalPlanDO::getProfessionName, reqVO.getProfessionName())
                .eqIfPresent(EvalPlanDO::getEvaluationMethod, reqVO.getEvaluationMethod())
                .eqIfPresent(EvalPlanDO::getPlanStatus, reqVO.getPlanStatus())
                .betweenIfPresent(EvalPlanDO::getRegistrationStartDate, reqVO.getRegistrationStartDate())
                .betweenIfPresent(EvalPlanDO::getEvaluationStartDate, reqVO.getEvaluationStartDate())
                .betweenIfPresent(EvalPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EvalPlanDO::getId));
    }

    default EvalPlanDO selectByPlanCode(String planCode) {
        return selectOne(EvalPlanDO::getPlanCode, planCode);
    }

    default List<EvalPlanDO> selectListByStatus(Integer planStatus) {
        return selectList(EvalPlanDO::getPlanStatus, planStatus);
    }

    default List<EvalPlanDO> selectListByStatuses(Collection<Integer> planStatuses) {
        return selectList(new LambdaQueryWrapperX<EvalPlanDO>()
                .in(EvalPlanDO::getPlanStatus, planStatuses));
    }

    default List<EvalPlanDO> selectListByProfessionId(Long professionId) {
        return selectList(EvalPlanDO::getProfessionId, professionId);
    }

    default List<EvalPlanDO> selectListByEvaluationMethod(String evaluationMethod) {
        return selectList(EvalPlanDO::getEvaluationMethod, evaluationMethod);
    }

}
